home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Newsletters / GEnieUnixNews / unxnl-09.92 < prev    next >
Text File  |  1992-12-27  |  32KB  |  831 lines

  1.  
  2.           _  _  _   _  _   _
  3.          // // //| // // \//     N E W S
  4.         //_// // |// //  /\\     Vol 3, Issue 7 - September 1992
  5.       R o u n d T a b l e (tm)
  6.  
  7.    Items of interest to participants of the GEnie Unix RoundTable
  8.  
  9.       The RoundTable SysOps are:
  10.       Andy Finkenstadt....ANDY         Rick Mobley.........LRARK
  11.       Gary Smith..........GARS         Brian Riley.........DELPHI
  12.       Mike Nolan..........MIKE.NOLAN   All Unix SysOps.....UNIX$
  13.    We strongly encourage you to contact any or all of us if you have -ANY-
  14.  comments or suggestions. This is -YOUR- RoundTable. We are here to make
  15.  your participation as pleasant and beneficial as possible.
  16.  
  17.  ED: editor notes - process n. continuing of an action (GARS) Gary Smith
  18.  ==
  19.  
  20.    Normally, we who dwell in Unixdom think of a process in much the same
  21.  way users of other languages think of functions or paradigms.  I made clear
  22.  I am using Mr. Webster's more common definition in my subject, because I
  23.  have been noting for several issues that the GEnie Unix RoundTable has been
  24.  in a continuing evolutionary process. That process has been defined and
  25.  guided by our users.
  26.  
  27.    Last issue, the addition of an Internet gateway on GEnie  and  resultant
  28.  help desk maintained primarily by lead SysOp Andy with able assistance from
  29.  Unix co-SysOp Mike Nolan, was the focus of this ongoing process.
  30.   [It must be noted that Andy extended himself in that effort far beyond any
  31.    reasonable call of duty.]
  32.  
  33.    The focal point this time is in the GEnie Unix RoundTable Software
  34.  Library. File support for two system platforms: Sun and NeXT, one public
  35.  domain kernel: Linux, Internet information and SysAdmin support has grown
  36.  until it was deemed necessary to give each its own library. This will make
  37.  browsing for files covering each much easier.
  38.    The libraries for each are as follows:
  39.      29.  Tools for System Administration
  40.      30.  Linux - Unix workalike for the 386 PC
  41.      31.  NeXT specific files and programs
  42.      32.  Sun workstaion specific files
  43.      33.  INTERNET files, information and programs
  44.  
  45.    This reorganization was the result of user need.  Thanks to each of you
  46.  for participating, giving us feedback, and for supporting the RoundTable.
  47.  You are defining the process, and we appreciate the opportunity to serve
  48.  as your hosts.
  49.  ----------
  50.  
  51.  WHO: NeXT Category Leader, Eric Tremblay
  52.  ===
  53.  
  54.  Hello Everyone, my name is Eric Tremblay most people here on GEnie call me
  55.  E.T. for short. One of the reasons I hang around in the Unix RT is because
  56.  of my great interest in the NeXT computer. As many of you know I have a
  57.  NeXTstation and I am currently developing software for the NeXT. Over the
  58.  past year there has been a lot of activity in the Unix RT for the NeXT
  59.  computer. The software library has grown by leaps and bounds and the
  60.  message area has also grown at a great pace. If you are interested about
  61.  the NeXT computer or would like to ask a question about it, I hope you will
  62.  drop by category 20. If you already have a NeXT I hope you will take a look
  63.  at the files found in the library. To find the file related to the NeXT just
  64.  to a search with the keyword NEXT. Hoping to see you there.
  65.  ----------
  66.  
  67.  Lead Sysop Notes (ANDY)  Andrew Finkenstadt
  68.  ================         Chief Sysop
  69.  
  70.  August saw the advent of the Internet Beta Test and the Unix RT's
  71.  contribution to supporting GEnie's Internet Gateway product and
  72.  providing a base of information about the Internet itself.  The
  73.  beta test proceeds.  (Full information available on page 207, or
  74.  in the Unix RT Libraries - search for GENIE or INTERNET.)
  75.  
  76.  In addition, Unix support is increasing.  Coherent is now online,
  77.  providing support for their 286 product (Coherent 3.2) and
  78.  386/486 product (Coherent 4.0) which has a feature of being
  79.  compatible with character-mode applications from SCO Unix.  Most
  80.  applications in source form compile "out of the box" and many
  81.  others port easily.
  82.  
  83.  Now featured in the Unix RT libraries are several back issues of
  84.  the SunSpot Sun Information Resource files from Rice University
  85.  in Houston Texas.  These files are informative and useful for
  86.  reading and learning about Sun and Unix.
  87.  
  88.  This month will see special guest conferences with Internet
  89.  personalities and more expanded Unix coverage.  Stay tuned for
  90.  more info on these things and more.
  91.  
  92.  As always the Unix Sysops keep an "open mailbox" policy - drop us
  93.  a line at any of our addresses, or at the special 'group' address
  94.  UNIX$ and we will try to answer your question as best as
  95.  possible.
  96.  ----------
  97.  
  98.  Down and Dirty: Quick Scripts that do something useful
  99.  ==============
  100.  
  101.  Creating empty files (LRARK)  Ricky Mobley
  102.  --------------------
  103.  If you'd like to use echo to create an empty file, you have to suppress
  104.  the newline: usually that means
  105.  
  106.  echo "\c" > logfile     # in Sys V     or
  107.  echo -n > logfile       # in BSD.      but
  108.  : > logfile             # is shorter to type and, so other posters say,
  109.                          # works even in shells where
  110.  > logfile               # doesn't.
  111.  sh -c '> target'
  112.  
  113.  (LRARK) Ricky Mobley also snarfed the following handy mail script:
  114.  
  115.  Question:
  116.  
  117.  I need a shell script (csh or sh) to send me mail after completion.
  118.  
  119.  
  120.  Answer:
  121.  
  122.  The popular answer was use mail:
  123.          mail -s "$0 done" ugolinia << EOS
  124.          Hey, $0 finished at `date`.
  125.          All these folks were on the system at the time:
  126.          `who`
  127.          EOS
  128.  ----------
  129.  
  130.  Appointment Calendar for your NeXTstation (E.TREMBLAY2) Eric "E.T." Tremblay
  131.  =========================================
  132.  
  133.               Remember an Important Meeting with calendar.
  134.                           Eric "E.T." Tremblay
  135.                               May 23, 1992
  136.  
  137.     Have your memory cells ever let you down? Did you ever miss an
  138.  important meeting or anniversary? I'm sure you answered yes to at least one
  139.  of the above questions. So what are you going to do about it? You can go on
  140.  as you did before or you can use your NeXT to help you get organized. What
  141.  you need is already in your machine the only thing holding you back from
  142.  using it is knowing that it's there. This little Unix utility is called
  143.  calendar and it's a part of every  NeXT computer.
  144.  
  145.     What does calendar do for you? It looks for a calendar text file in your
  146.  local directory, and if it finds the file it looks therein for today's date.
  147.  If it finds a line with the current date, it will send you electronic mail
  148.  containing the corresponding message.Found below is a simple example of the
  149.  calendar text file.
  150.  
  151.  # Example of a calendar file located in a users local directory.
  152.  # This calendar file belongs to Joe Blow.
  153.  # This is a remark statement.
  154.  January 10  This is the message that will be sent in the e-mail.
  155.  May 23  This is another message that will be sent...
  156.  September 19  Happy birthday John!
  157.  
  158.  You can make your text file as big as you want and include as many events
  159.  as you wish. The only rule you have to follow are that the date be in the
  160.  above format, you can use wild cards etc. Consult the Unix documentation
  161.  using the Digital Librarian with the keyword calendar for further details
  162.  about the format of the file.
  163.  
  164.  Once your calendar file is ready, you most likely want your reminders to be
  165.  sent automatically. Well, that is not hard to do either. What you have to
  166.  do is modify a file called rc.local found in the /etc directory. What this
  167.  modification will do is that every time you power-up your NeXT, it will
  168.  execute this script which in turn will execute the calendar command. If
  169.  your NeXT computer is always on you need to execute the calendar command
  170.  using another method. Please consult Digital Librarian with the keyword
  171.  crontab. The difference is that when the NeXT is always on it would be more
  172.  appropriate to execute calendar command at a specific time on each day
  173.  using the crontab file.
  174.  
  175.  Here's an example of what the file called rc.local found in the /etc
  176.  directory looks like. What you have to do is load the rc.local file in a
  177.  text editor and add the "calendar -" command to the script. Then save the
  178.  edited file and the next time you boot your NeXT you will receive and
  179.  electronic mail reminding you of a special event. (If you have an event for
  180.  that day of coarse.)
  181.  
  182.  /etc/rc.local
  183.  #
  184.  # This script is for augmenting the standard startup commands. It is
  185.  # executed automatically by the system during boot up.
  186.  #
  187.  # In its released form, this script does nothing. you may customize
  188.  # it to your heart's content.
  189.  #
  190.  etc...
  191.  #
  192.  # Run you own commands here
  193.  #
  194.  (echo '.')                   >/dev/console
  195.  # calendar utility added here
  196.  calendar -
  197.  # It is very important to include the "-" sign after the calendar
  198.  # command
  199.  
  200.  I hope that this article will help you take advantage of a very useful
  201.  command found in Unix library and make you more productive using your
  202.  NeXT computer
  203.  
  204.  This article appeared in the magazine called InterFace Volume 4 No.7 August
  205.  1992 published by Le Club MacIntosh de Montreal 2250 rue Guy, suite 303
  206.  Montreal (Quebec) H3H 2N2.
  207.  ----------
  208.  
  209.  Upload Contest Winners for August (ANDY)
  210.  ================================
  211.   
  212.  Sub: andy sep 92
  213.  
  214.  Upload contest winners
  215.  
  216.  For the month of August the upload contest winners are
  217.  A.Rosenbalm & J.Wisniewsk2 - congratulations!  Each of them won
  218.  ONE free day in the Unix RT.  For details on how you can win free
  219.  time in the Unix RT, download the file CONTEST.RULES, file #2346.
  220.  ----------
  221.  
  222.  usr/local: Items (scripts and news) snarfed from various sources
  223.  =========
  224.  
  225.  The first entry consists of methods of dealing with chmod in alternate
  226.  forms, found by (LRARK) Ricky Mobley in comp.unix.shell
  227.  
  228.  Question:
  229.  
  230.  I am looking for a sh routine to return a numerical value for a file/directory.
  231.  i.e. the files permissions are -rwxr-xr-x it would return a 755.
  232.  
  233.  
  234.  Answers:
  235.  -----------------------------------------------------------------------
  236.  From: hsc@sybase.com (Howard Cohen)
  237.  Newsgroups: comp.unix.shell
  238.  Subject: Re: Octal chmod status
  239.  Date: 14 Aug 92 00:30:18 GMT
  240.  
  241.  #!/bin/sh
  242.  
  243.  LSPERMS=`ls -l "$1" | sed -e "s:^\([^  ][^     ]*\).*:\1:"`
  244.  USR=`echo $LSPERMS X| sed -e "s:.\(...\).*:\1:"`
  245.  GRP=`echo $LSPERMS X| sed -e "s:....\(...\).*:\1:"`
  246.  OTH=`echo $LSPERMS X| sed -e "s:.......\(...\).*:\1:"`
  247.  
  248.  PERMS=""
  249.  for elem in $USR $GRP $OTH
  250.  do
  251.       case "$elem" in
  252.           ---)    PERMS="${PERMS}0";;
  253.           --x)    PERMS="${PERMS}1";;
  254.           -w-)    PERMS="${PERMS}2";;
  255.           -wx)    PERMS="${PERMS}3";;
  256.           r--)    PERMS="${PERMS}4";;
  257.           r-x)    PERMS="${PERMS}5";;
  258.           rw-)    PERMS="${PERMS}6";;
  259.           rwx)    PERMS="${PERMS}7";;
  260.       esac
  261.  done
  262.  
  263.  echo $PERMS
  264.  
  265.  -----------------------------------------------------------------------
  266.  From: mju@mudos.ann-arbor.mi.us (Marc Unangst)
  267.  Newsgroups: comp.unix.shell
  268.  Subject: Re: Octal chmod status
  269.  Date: 15 Aug 92 05:11:08 GMT
  270.  
  271.  #include <stdio.h>
  272.  #include <sys/types.h>
  273.  #include <sys/stat.h>
  274.  #include <errno.h>
  275.  
  276.  int
  277.  main(int argc, char **argv)
  278.  {
  279.    struct stat statbuf;
  280.  
  281.    if(argc != 2) {
  282.      fprintf(stderr, "%s: usage: %s file\n", argv[0], argv[0]);
  283.      exit(1);
  284.    }
  285.  
  286.    if(stat(argv[1], &statbuf) != 0) {
  287.      fprintf(stderr, "%s: can't stat file %s: %s\n", argv[0], argv[1],
  288.              strerror(errno));
  289.      exit(1);
  290.    }
  291.  
  292.    printf("%o\n", statbuf.st_mode & 07777);
  293.    exit(0);
  294.  }
  295.  -----------------------------------------------------------------------
  296.  From: tchrist@convex.COM (Tom Christiansen)
  297.  Newsgroups: comp.unix.shell
  298.  Subject: Re: Octal chmod status
  299.  Date: 18 Aug 92 18:16:09 GMT
  300.  
  301.      perl -e 'printf("%04o\n", (stat($ARGV[0]))[2] & 07777)'
  302.  
  303.  -----------------------------------------------------------------------
  304.  From: tchrist@convex.COM (Tom Christiansen)
  305.  Newsgroups: comp.unix.shell
  306.  Subject: Re: Octal chmod status
  307.  Date: 19 Aug 92 14:30:59 GMT
  308.  
  309.          [perl solution, optimized for readability ---Chip]
  310.  
  311.      require 'stat.pl';
  312.      @sb = stat($ARGV[0]);
  313.      printf("%04o\n", $sb[$ST_MODE]);
  314.  
  315.  -----------------------------------------------------------------------
  316.  From: rouben@math13.math.umbc.edu (Rouben Rostamian)
  317.  Newsgroups: comp.unix.shell
  318.  Subject: Re: Help with directories!
  319.  Date: 26 Aug 92 14:50:29 GMT
  320.  
  321.  Create a file called convert.awk, containing:
  322.  
  323.  {       for (i=2; i<=10; i++) {
  324.                  n = 2*n
  325.                  if ( substr($0,i,1) != "-" )
  326.                          n++;
  327.          }
  328.          printf ("%o\n", n)
  329.  }
  330.  
  331.  Then the apply the command:
  332.  echo -rwxr-xr-x | awk -f convert.awk
  333.  to get 755.
  334.  
  335.  If you have nawk, you can write the script a bit more elegantly as:
  336.  
  337.  {       for (i=2; i<=10; i++)
  338.                  n = 2*n + ( substr($0,i,1) != "-" ? 1 : 0 )
  339.          printf ("%o\n", n)
  340.  }
  341.  
  342.  ----------
  343.  
  344.  The following is a tar file organizer found by (GARS) Gary Smith in
  345.  alt.sources.
  346.  
  347.  Article 2682 of alt.sources:
  348.  Path: glsrk!lrark!ddi1!uunet!uunet!decwrl!intertech-nh!utashiro
  349.  From: utashiro@InterTech.COM (Kazumasa Utashiro)
  350.  Newsgroups: comp.lang.perl,alt.sources
  351.  Subject: TARO: tar organizer (Re: Tar Perl and Compress)
  352.  Keywords: tar compress perl
  353.  Message-ID: <1992Jun16.223848.6262@InterTech.COM>
  354.  Date: 16 Jun 92 22:38:48 GMT
  355.  References: <1992Jun16.214035.490@cse.uta.edu>
  356.  Followup-To: comp.lang.perl
  357.  Organization: InterTech Data Systems, Inc., Cupertino, CA
  358.  
  359.  Archive-name: taro
  360.  Submitted-by: utashiro@sra.co.jp
  361.  
  362.  In article <1992Jun16.214035.490@cse.uta.edu>
  363.          turbo@cse.uta.edu (Chris Turbeville) writes:
  364.  
  365.  > I'd like to be able to add files to tar.Z files without needing the disk
  366.  > space to hold the uncompressed tar.
  367.  
  368.  This is not exactly what you want but probably very closed.
  369.  Using TARO, you can delete specified file from input tar
  370.  stream.  What you need is adding a feature to concatinate
  371.  two tar streams.  Workaround is dealing with terminator of
  372.  tar format which is two continuous null header block.
  373.  
  374.  I made this program to retrieve some files in compressed tar
  375.  file in tar archive on tape (what a brain damaged format!).
  376.  
  377.  --utashiro
  378.  
  379.  #!/usr/local/bin/perl
  380.  ;#
  381.  ;# taro: tar organizer
  382.  ;#      Copyright (c) 1991,1992 srekcah@sra.co.jp
  383.  ;#      October 7 1991
  384.  ;#
  385.  ;#      Maintained by utashiro@sra.co.jp
  386.  ;;      $rcsid = '$Id: taro,v 1.3 1992/04/13 18:30:37 utashiro Exp $';
  387.  ;#
  388.  $usage = <<_;
  389.  Usage:
  390.          taro list tar-file                              # list
  391.          taro pick tar-file pattern [ pattern ... ]      # pick up some files
  392.          taro throw tar-file pattern [ pattern ... ]     # throw away some files
  393.          taro cat tar-file [ name ... ]                  # show file contents
  394.          taro edit tar-file perl-script                  # edit filename
  395.          taro s/foo/bar/ tar-file                        # short-cut for edit
  396.  _
  397.  ;#
  398.  ;# SEE ALSO
  399.  ;#      tar(1), tar(5)
  400.  ;#
  401.  push(@INC, 'c:/etc/perl');
  402.  require('ctime.pl');
  403.  
  404.  $header_size = 512;
  405.  $header_format = "a100 a8 a8 a8 a12 a12 a8 a a100 a*";
  406.  $nullblock = "\0" x $header_size;
  407.  %mode=(1, '--x', 2, '-r-', 3, '-wx', 4, 'r--', 5, 'r-x', 6, 'rw-', 7, 'rwx');
  408.  
  409.  # initialize header index
  410.  $i = 0;
  411.  for (split(/ / ,'name mode uid gid size mtime chksum linkflag linkname pad'))
  412.  {
  413.     &eval(sprintf('$%s_i = %d;', $_, $i++));
  414.  }
  415.  
  416.  # option handling
  417.  $opts = 'dtv';
  418.  while ($_ = $ARGV[0], /^-/ && shift) {
  419.      next unless ($car, $cdr) = /^-?(.)(.*)/;
  420.      if (index($opts, "$car:") >= $[) {
  421.          &eval("\$opt_$car = length(\$cdr) ? \$cdr : \@ARGV ? shift : &usage");
  422.          next;
  423.      }
  424.      if (index($opts, $car) >= $[) {
  425.          &eval("\$opt_$car++"); $_ = $cdr; redo;
  426.      }
  427.      &usage("Unknown option: $car\n\n");
  428.  }
  429.  
  430.  $command = shift || &usage;     # 1st argument is command
  431.  $tarfile = shift || '-';        # 2nd argument is archive file
  432.  command: {
  433.      if ($command eq 'list') {
  434.          last;
  435.      }
  436.      if ($command eq 'pick' || $command eq 'throw') {
  437.          @patterns = @ARGV;
  438.          for (@patterns) {
  439.              $_ = &wildcard($_);
  440.          }
  441.          ($command, $negative) = ('pick', '!') if ($command eq 'throw');
  442.          $sub = "sub pickit { local(\$_) = \@_; $negative(/"
  443.              . join('/ || /', @patterns) . "/); }\n";
  444.          print STDERR $sub if $opt_d;
  445.          &eval($sub);
  446.          last;
  447.      }
  448.      if ($command eq 'cat' || $command eq 'extract') {
  449.          $catall++ if (@ARGV == 0);
  450.          for (@ARGV) {
  451.              $cat{$_}++;
  452.              $cat_cnt++;
  453.          }
  454.          last;
  455.      }
  456.      if ($command eq 'edit') {
  457.          $script = shift;
  458.      }
  459.      if ($command =~ m/^s/) {
  460.          $script = $command;
  461.          $command = 'edit';
  462.      }
  463.      if ($command eq 'edit') {
  464.          $sub_edit = "sub edit { local(\$_)=\@_; $script; \$_; }\n";
  465.          &eval($sub_edit);
  466.          print STDERR $sub_edit if $opt_d;
  467.      }
  468.      else {
  469.          print "Unknown command: $command\n";
  470.          &usage;
  471.      }
  472.  }
  473.  
  474.  open(TAR, $tarfile) || die("$tarfile: $!\n");
  475.  open(TAR, '-|') || exec('zcat', $tarfile) || die("zcat: $!\n")
  476.      if ($tarfile =~ /\.Z$/);
  477.  while (($s = read(TAR, $header, $header_size)) == $header_size) {
  478.      $print_header = $print_body = 1;
  479.      if ($header eq $nullblock) {
  480.          print $header if ($command eq 'pick' || $command eq 'edit');
  481.          last if (++$null_count == 2);
  482.          next;
  483.      }
  484.      $null_count = 0;
  485.  
  486.      @header = unpack($header_format, $header);
  487.      ($name = $header[$name_i]) =~ s/\0*$//;
  488.  
  489.      if ($command eq 'list') {
  490.          $print_header = $print_body = 0;
  491.          &show_header(@header);
  492.      }
  493.      elsif ($command eq 'pick') {
  494.          $print_header = $print_body = &pickit($name);
  495.      }
  496.      elsif ($command eq 'cat' || $command eq 'extract') {
  497.          $print_header = $print_body = 0;
  498.          $catit = $catall || $cat{$name};
  499.          $catit = 0 if ($header[$linkflag_i] =~ /[12]/);
  500.      }
  501.      elsif ($command eq 'edit') {
  502.          $header[$name_i] = &edit($header[$name_i]);
  503.          $header[$linkname_i] = &edit($header[$linkname_i])
  504.              if ($header[$linkflag_i] =~ /1/);
  505.          $header = &make_header(@header);
  506.          $print_header = $print_body = 0 if ($header[$name_i] =~ /^\0/);
  507.      }
  508.  
  509.      print $header if $print_header;
  510.  
  511.      if ($catit && $command eq 'extract') {
  512.          if ($name =~ m|/$|) {
  513.              chop($name);
  514.              mkdir($name, oct($header[$mode_i])) || warn("$name: $!\n");
  515.              next;
  516.          } else {
  517.              open(OUT, ">$name") || warn("$name: $!\n");
  518.              select(OUT);
  519.          }
  520.      }
  521.      $bufsize = 8192;
  522.      $size = oct($header[$size_i]);
  523.      $size = 0 if ($header[$linkflag_i] =~ /1/);
  524.      while ($size > 0) {
  525.          $bufsize = 512 if ($size < $bufsize);
  526.          if (($s = read(TAR, $buf, $bufsize)) != $bufsize) {
  527.              print "bufsize = $bufsize, size = $size, s = $s\n" if $opt_d;
  528.              die "Illegal EOF!\n";
  529.          }
  530.          print substr($buf, 0, $size) if $catit;
  531.          print $buf if $print_body;
  532.          $size -= $bufsize;
  533.      }
  534.      exit if ($catit && !--$cat_cnt);
  535.      if ($catit && $command eq 'extract') {
  536.          select(STDOUT);
  537.          close(OUT);
  538.          chmod oct($header[$mode_i]), $name;
  539.      }
  540.  }
  541.  close(TAR);
  542.  
  543.  exit(0);
  544.  
  545.  ######################################################################
  546.  
  547.  sub usage {
  548.      print $usage;
  549.      exit 1;
  550.  }
  551.  
  552.  ;#
  553.  ;# make header block by recalculating checksum
  554.  ;#
  555.  sub make_header {
  556.      local(@header, $header) = @_;
  557.      $header = pack($header_format, @header[0..5], ' ' x 8, @header[7..9]);
  558.      $header[6] = sprintf("% 6o\0 ", unpack("%16C*", $header));
  559.      pack($header_format, @header);
  560.  }
  561.  
  562.  ;#
  563.  ;# parse header block
  564.  ;#
  565.  sub parse_header {
  566.      local(@h) = @_;
  567.      $h[$name_i] =~ s/\0+$//;
  568.      $h[$linkname_i] =~ s/\0+$//;
  569.      for (2..6) {
  570.          $h[$_] =~ s/ \0//g;
  571.          $h[$_] = oct($h[$_]);
  572.      }
  573.      @h;
  574.  }
  575.  
  576.  ;#
  577.  ;# show "tar tv" like information from header
  578.  ;#
  579.  sub show_header {
  580.      ($name, $mode, $uid, $gid, $size, $mtime, $chksum, $linkflag, $linkname)
  581.          = &parse_header(@_);
  582.      $ctime = &ctime($mtime);
  583.      chop($ctime);
  584.  
  585.      # Sat Oct  5 10:46:00 PDT 1991
  586.      # 0-->            16---->
  587.      substr($ctime, 16, length($ctime) - 21) = '';
  588.      substr($ctime, 0, 4) = '';
  589.      $ctime =~ s/ (\d:\d\d)/0\1/;        # keep compatibility with tar
  590.  
  591.      printf("%s%3d/%d%7d %s ", &modeline($mode), $uid, $gid, $size, $ctime)
  592.          unless $opt_t;          # terse
  593.  
  594.      print $name;
  595.  
  596.      if ($linkflag eq '1') {     # hard link
  597.          print " linked to ", $linkname;
  598.      }
  599.      if ($linkflag eq '2') {     # symbolic link
  600.          print " symbolic link to ", $linkname;
  601.      }
  602.      print " [chksum=$chksum]" if $opt_v;
  603.      print "\n";
  604.  }
  605.  
  606.  ;#
  607.  ;# make modeline like 'rw-r--r--'
  608.  ;#
  609.  sub modeline {
  610.      local($u, $g, $o) = $_[$[] =~ /(\d)(\d)(\d) \0$/;
  611.      $mode{$u} . $mode{$g} . $mode{$o};
  612.  }
  613.  
  614.  ;#
  615.  ;# wildcard to regex convert
  616.  ;#
  617.  sub wildcard {
  618.      local($_) = @_;
  619.      s#\\?.#$_ = $&; s/\\?([_0-9A-Za-z])/$1/ || /\\./ || s/[*]/.*/ ||
  620.          s/[|]/\$|^/ || tr/?{,}[]\-/.(|)[]\-/ || s/./\\$&/; $_;#ge;
  621.      length($_) ? "(^|\\/)$_\(\\0|\$|\\/)" : undef;
  622.  }
  623.  
  624.  ;#
  625.  ;# eval with error handling
  626.  ;#
  627.  sub eval {
  628.      local($exp) = @_;
  629.      eval $exp;
  630.      if ($@ ne '') {
  631.          local($package, $filename, $line) = caller;
  632.          warn "eval failed on line $line in file $filename\n";
  633.          warn "exp = \"$exp\"\n";
  634.          warn $@;
  635.          exit 1;
  636.      }
  637.  }
  638.  
  639.  ----------
  640.  
  641.  Tutorials
  642.  =========
  643.  
  644.  VI Unix Text Editor, Last Installment  (GARS) Gary Smith
  645.  == ----------------  some closing thoughts
  646.  
  647.    This will be the last installment in my series on VI, the Unix text
  648.  editor, created originally as a VIsual (full screen) display of EX,
  649.  both derived from ED. It is important that this linage be remembered,
  650.  because there are features of ED that are available from EX and VI.
  651.  Further, VI and EX are so completely related, it is quite impossible
  652.  to process a file with VI without using some feature of EX.
  653.  
  654.    Other than again reminding everyone that VI is modal, and mnemonic,
  655.  with mnemonics in one mode having far different results than they
  656.  would in another mode,I will not be repeating lessons and tips given
  657.  in previous installments. It is suggested the user capture all the
  658.  installments and bundle them into one handy VI reference.
  659.  
  660.    I like VI. It is extremely powerful, and one of those ubiquitous Unix
  661.  processes that comes with every platform. Learning VI is to your
  662.  advantage, should you ever want to edit text on any other system. You
  663.  will. It is my personal, unsubstantiated guess that as much as 90%
  664.  of a session can be spent in some editing task. After all, what are
  665.  you doing when you debug a source file except editing?  Once you have
  666.  mastered VI there are some features that you will rue giving up when
  667.  moving to another editor. Touch typists especially will miss the fact
  668.  that 90% of the commands are in the form of one or two keystrokes and
  669.  on the home row! This feature alone makes ASCII text editing quicker in
  670.  VI than in any other editor, given equal proficiency.  One other very
  671.  nice feature is that the keystroke to undo a previous command is often
  672.  intuitively matched to the key that produced the original command.  Maybe
  673.  VI's single strongest saving grace is that, while it does not create a
  674.  backup file, it does maintain a log. This log can actually permit you to
  675.  recreate a file after such catastrophic events as a power failure during
  676.  an edit.
  677.  
  678.    VI is one of those magical creatures that have layer upon layer of
  679.  hidden secrets. It was Bennett Falk in his "MicroTimes" (1) column who
  680.  first made me aware that you could literally spend an entire session
  681.  in VI, and accomplish any task you chose to execute, while never leaving
  682.  the editor. There is a valid reason for doing precisely that. It gives
  683.  you the ability to interactively debug a program. edit...compile...run...
  684.  edit...test...compile...execute, all from within VI. The primary tool for
  685.  performing this bit of magic is actually a EX command that is executed
  686.  from the command mode.
  687.  
  688.              :!cmdx run command cmdx
  689.  
  690.    The :! command provides you with a lot of flexibility totally lacking in
  691.  other editors. A simple example would be a directory listing  :!ls.
  692.  The :! command is called a shell escape.
  693.  
  694.    You can also shell escape from the cursor mode using ! to invoke the
  695.  command. Be careful, though. This is a bit tricky, since you are not
  696.  executing the command directly, but rather you feed a segment of the file
  697.  you are editing as input that replaces that part of the program's output.
  698.  This makes it extremely powerful as an interactive test tool, but also very
  699.  risky until you master the technique. It is suggested you play with this
  700.  concept, using a small script like 'today' available in the library and
  701.  back issues of this newsletter in two separate incarnations.
  702.  
  703.    Now, we add a bit of real trickery. There are 26 buffers at your disposal
  704.  in VI. You can Yank text and Put it through those buffers. There is no rule
  705.  that says you can't place a command like "!fmt" into a buffer and then
  706.  executed by typing "@" and the buffer name.
  707.  
  708.    What this does is permit you to use VI as true general file interface and
  709.  debugging platform.
  710.  
  711.    Another risky tool that we touched on is recursive macros. Never ever set
  712.  up a macro like:
  713.  
  714.     map! usr /usr/group
  715.  
  716.    The sequence you use to create a macro must not contain the sequence
  717.  defined. The reason is the sequence in macro text will be expanded
  718.  geometrically, soon consuming all available resources. Should you invoke
  719.  such a macro try hitting BREAK, DELETE, Control D and Control C. One
  720.  of these will usually interrupt the sequence.
  721.  
  722.    VI is extremely powerful. Learn to use it. It is the one editor that is
  723.  available on every platform, and performs precisely the same way on each
  724.  platform, provided curses has correctly defined your terminal. If you
  725.  prefer emacs or one of it's cousins like JOVE, that's fine. You won't
  726.  get an argument from me regarding your preference. Do get comfortable
  727.  with VI, and use it often enough to stay familiar with it. Like a good
  728.  carpenter, you need to take care of your tools. They in turn will take
  729.  care of you.
  730.  
  731.  
  732.  1. MicroTimes, California's Computer Magazine, 5951 Canning Street,
  733.     Oakland, CA  94609
  734.  
  735.  Addendum: The following is a list of VI/EX related files available
  736.            in the GEnie Unix RoundTable library, compiled by fellow
  737.            SysOp (LRARK) Ricky Mobley
  738.            **EDitor note: This list contains ONLY those files ported
  739.                           from the VI/EX archives. There are many others
  740.                           NOT included in this list. gars
  741.  #  Mostly files on vi.
  742.  #
  743.  #  Index of archive:    alf.uib.no (129.177.30.3)
  744.  #  Filearea:            /pub/lpf/misc
  745.  #  Archive maintainer:  Ove Ruben R Olsen (rubenro@viggo.blh.no)
  746.  #  Archive updated:     Thu Aug 22 18:06:23 GMT 1991
  747.  #
  748.  
  749.  In the macros/ directory there exists macros for vi. Look at file
  750.  macros/INDEX.
  751.  
  752.  UCB = University of California, Berkley. (Hometown of vi)
  753.  
  754.  ------------------
  755.  INDEX                 This file. *
  756.  WHOandWHERE           A 'thank you' too all who have submitted to the
  757.  archive.
  758.  
  759.  ex.changes.Z          ex changes from version to version. UCB-dist.
  760.  ex.fix.Z              An Encore ex fix.
  761.  ex.reference.Z        ex Reference Manual. UCB-dist.
  762.  ex.summary.Z          ex Command Summary. UCB-dist.
  763.  jl.ex.ref.Z           Another reference for vi.
  764.  learn-vi.tar.Z        LVI - The Learners Introduction to VI. Interactive.
  765.  nvi.tar.Z             Novice VI.
  766.  shell-100.BetaA.Z     Conversion table between different shells.
  767.  vi.1.Z                Vi formatted manual.
  768.  vi.132.Z              A tip on using vi on vt-100 with 132 columns.
  769.  vi.apwh.ms.Z          Vi Command & Function Reference. UCB-dist.
  770.  vi.beiners.Z          Vi beginners guide.
  771.  vi.card.tex.Z         Vi reference card in TeX. Found inside
  772.  learn-vi.tar.Z
  773.  vi.chars.Z            Appendix: character functions. UCB-dist.
  774.  vi.course.Z           A course on using vi. Paper.
  775.  vi.course.tar.Z       A course package on using vi. Paper.
  776.  vi.help.Z             Vi reference card. Found inside learn-vi.tar.Z
  777.  vi.intro.Z            Introduction on Display Editing with Vi. UCB-dist.
  778.  vi.intro.ps.Z         Vi.intro in PostScript format. UCB-dist.
  779.  vi.macros.Z           Macros, Abbreviations, and Buffers.
  780.  vi.macroDoc.tar.Z     Two docs describing macros in vi.
  781.                        Sample exrc file incl.
  782.  vi.man.tut.Z          VI manual-page with a tutor.
  783.  vi.multfile.Z         A doc on how to work with multiple files in vi.
  784.  vi.online-200.tar.Z   Vi ON-LINE HELP with 'windows for vi'. Version 2.00
  785.  vi.passwd.Z           A script for "secure" editing of /etc/passwd.
  786.  vi.passwd.fix.Z       A fix to vi.passwd.fix.Z
  787.  vi.patch.Z            Path to fix a "security" hole in VI.
  788.  vi.quick.Z            Vi Quick reference card.
  789.  vi.ref.Z              UNIX VI quick reference card.
  790.  vi.refchrt.Z          Vi reference chart.
  791.  vi.reference.Z        Vi reference. Version 7.
  792.  vi.reference.ms.Z     Vi reference for typesetters.
  793.  vi.sigint.fix         A src fix for vi dealing with 'sigint'.
  794.  vi.song.Z             A song about vi.
  795.  vi.summary.Z          Vi / ex Quick reference. UCB-dist.
  796.  vi.startup.d.Z        NetNews discussion about ex:COMMAND / vi:COMMAND
  797.                        feature.
  798.  vi.tabs.Z             A tip on tabs in vi.
  799.  vi.tags.Z             A paper on a tag-tech.
  800.  vi.tagStack.Z         Patch for vaxen to make tag stack avail. Fixes for sun.
  801.  vi.tips.Z             Beginners tips on vi.
  802.  vi.tutor.Z            An interactive tutor for vi.
  803.  vi.ucb.tar.Z          The whole UCB-dist package. package. *
  804.  
  805.  vi-buffer.el.Z        Invoke vi inside emacs. *
  806.  
  807.  ----------
  808.    ---------------
  809.   REMINDER - This newsletter is being sent to you 'by request'. If you do
  810.  not wish to keep receiving it, e-mail a stop notice to GARS. On the other
  811.  hand, we would very much appreciate it if you would pass the word that we
  812.  do distribute this item near the tenth (10th) of the month of issue to any-
  813.  one on GEnie who requests it.
  814.    P L E A S E  also remember contributions are most welcome. Please e-mail
  815.  items and/or suggestions to GARS.
  816.  
  817.   (EOF)
  818.  
  819.  Trademark and Copyright notices:
  820.  Unix is a Trademark of UNIX System Laboratories, Inc.; GEnie, LiveWire, and
  821.  RoundTable are Trademarks of General Electric Information Services  Company;
  822.  Xenix and ms-dos are Trademarks of  Microsoft  Corporation; NeXT NeXTstation
  823.  and NeXTstep are Trademarks of NeXT Computer Systems, Inc., Coherent is a
  824.  Trademark of Mark Williams Company, Sun is a Trademark of Sun Microsystems,
  825.  Inc.
  826.  
  827.  The contents of this newsletter are copyright(c) 1992 and may be copied whole
  828.  or in part only if original  credit is included. The GEnie UNIX RoundTable is
  829.  not affiliated with AT&T or UNIX System Laboratories, Inc.
  830.  
  831.